<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="renderer" content="webkit"/>
  <meta name="force-rendering" content="webkit"/>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
  <title>新增广告</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="/bower_components/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="/bower_components/Ionicons/css/ionicons.min.css">
  <link rel="stylesheet" href="/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
  <link rel="stylesheet" href="/dist/css/AdminLTE.min.css">
  <link rel="stylesheet" href="/dist/css/skins/_all-skins.min.css">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <!--头部-->
  <header id="headerDiv" class="main-header">
    <!--#include  file="/pages/admin/header.html"-->
  </header>

  <!--左侧边栏 -->
  <aside id="sidebarDiv" class="main-sidebar">
    <!--#include  file="/pages/admin/sidebar.html"-->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        <small>新建广告</small>
      </h1>
      <ol class="breadcrumb">
        <li><i class="fa fa-buysellads"></i> 广告管理</li>
        <li><a href="javascript:goBack();">广告列表</a></li>
        <li>新建广告</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">新建广告</h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form id="dataForm" class="form-horizontal">
              <input type="hidden" id="id">
              <div class="box-body">
                <div class="form-group">
                  <label for="budgetid" class="col-sm-2 control-label">预算名称</label>
                  <div class="col-sm-4">
                    <select id="budgetid" class="form-control" name="budgetid">
                    </select>
                  </div>
                </div>

                <div class="form-group">
                  <label for="gameid" class="col-sm-2 control-label">所属游戏</label>
                  <div class="col-sm-4">
                    <select id="gameid" class="form-control" name="gameid">
                    </select>
                  </div>
                </div>

                <div class="form-group">
                  <label for="adsname" class="col-sm-2 control-label">广告名称</label>
                  <div class="col-sm-4">
                    <input type="text" name="adsname" maxlength="50" class="form-control" id="adsname">
                  </div>
                </div>

                <div class="form-group">
                  <label for="styleid" class="col-sm-2 control-label">广告样式</label>
                  <div class="col-sm-2">
                    <select id="styleid" class="form-control">
                      <option value="1">WAB移动横幅</option>
                      <option value="2">WAB移动漂浮</option>
                    </select>
                  </div>
                </div>

                <div class="form-group">
                  <label for="size" class="col-sm-2 control-label">广告尺寸</label>
                  <div class="col-sm-2">
                    <select id="size" class="form-control">
                    </select>
                    <input type="hidden" name="width" class="form-control" id="width">
                    <input type="hidden" name="height" class="form-control" id="height">
                  </div>
                </div>


                <div class="form-group">
                  <label for="mainImage" class="col-sm-2 control-label">上传封面图片</label>
                  <div class="col-sm-2">
                    <input type="file" name="mainImage" id="mainImage" onclick="checkMainImage()" style="display:none;"/>
                    <a href="javascript:void(0);" onclick="AddImg()">
                      <img id="mainPicture" src="" style="height: 100px; width: 200px; display: inline; margin-bottom: 5px;" border="1" />
                    </a>
                  </div>
                </div>
                <div class="form-group">
                  <label for="gifImage" class="col-sm-2 control-label">上传动态图片</label>
                  <div class="col-sm-2">
                    <input type="file" name="gifImage" id="gifImage" style="display:none;"/>
                    <a href="javascript:void(0);" onclick="AddGif()">
                      <img id="gifPicture" src="" style="height: 100px; width: 200px; display: inline; margin-bottom: 5px;" border="1" />
                    </a>
                  </div>
                </div>
                <div class="form-group">
                  <label for="mainVideo" class="col-sm-2 control-label">上传视频</label>
                  <div class="col-sm-4">
                    <input type="file" name="mainVideo" id="mainVideo" class="hidden"/>
                    <a href="javascript:void(0);" onclick="AddVideo()">
                      <input type="text" readonly id="videUrl" maxlength="200" class="form-control">
                    </a>
                  </div>
                </div>
                <div class="form-group">
                  <label for="url" class="col-sm-2 control-label">广告地址</label>
                  <div class="col-sm-4">
                    <input type="text" name="url" maxlength="200" class="form-control" id="url">
                  </div>
                </div>
                <div class="form-group">
                  <label for="priority" class="col-sm-2 control-label">广告权重</label>
                  <div class="col-sm-4">
                    <input type="number" name="priority" maxlength="200" class="form-control" id="priority">
                  </div>
                </div>

                <hr/>

                <div class="form-group">
                  <label for="type" class="col-sm-2 control-label">计费模式</label>
                  <div class="col-sm-2">
                    <select id="type" class="form-control">
                      <!--<option value="cpc">cpc</option>-->
                      <!--<option value="cpa">cpa</option>-->
                      <!--<option value="cpm">cpm</option>-->
                    </select>
                  </div>
                </div>

                <div class="form-group">
                  <label  class="col-sm-2 control-label">投放流量类型</label>
                  <div class="col-sm-4">
                    <!--<label class="radio-inline">-->
                    <!--<input type="radio" value="web" name="flow" checked>WEB桌面网页</label>-->
                    <label class="radio-inline">
                      <input type="radio" value="wab" name="flow" checked>WAB移动网页</label>
                    <label class="radio-inline">
                      <input type="radio" value="app" name="flow">APP移动端</label>
                    <label class="radio-inline">
                      <input type="radio" value="mnp" name="flow">小程序</label>
                  </div>
                </div>

                <div class="form-group">
                  <label  class="col-sm-2 control-label">投放浏览器</label>
                  <div class="col-sm-4">
                    <label class="radio-inline">
                      <input name="isbrowser" type="radio" value="0" checked>不限</label>
                    <label class="radio-inline">
                      <input name="isbrowser" type="radio" value="1" >指定浏览器</label>
                    <label class="radio-inline">
                      <input name="isbrowser" type="radio" value="2" >排除浏览器</label>
                  </div>
                </div>

                <div class="form-group">
                  <label  class="col-sm-2 control-label"></label>
                  <div class="col-sm-4">
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="wechat" name="browser" >微信</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="QQ" name="browser" >QQ</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="Safari" name="browser" >Safari</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="UC" name="browser" >UC</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="Chrome" name="browser" >Chrome</label>
                  </div>
                </div>

                <div class="form-group">
                  <label for="network" class="col-sm-2 control-label">投放网络类型</label>
                  <div class="col-sm-2">
                    <select id="network" name="network" class="form-control">
                      <option value="">不限</option>
                      <option value="WIFI">WIFI</option>
                      <option value="4G">4G</option>
                    </select>
                  </div>
                </div>

                <div class="form-group">
                  <label  class="col-sm-2 control-label">结束日期</label>
                  <div class="col-sm-4">
                    <label class="radio-inline">
                      <input type="radio" value="0" name="end_date" checked>没有结束日期
                    </label>
                    <label class="radio-inline">
                      <input type="radio" value="1" name="end_date">
                      <input id="end_date" disabled placeholder="YYYY-MM-DD" type="text" class="form-control">
                    </label>
                  </div>

                </div>

                <div class="form-group">
                  <label  class="col-sm-2 control-label">站长限制</label>
                  <div class="col-sm-4">
                    <label class="radio-inline">
                      <input type="radio" value="0" name="stationmaster" checked>不限</label>
                    <label class="radio-inline">
                      <input type="radio" value="1" name="stationmaster">允许以下站长</label>
                    <label class="radio-inline">
                      <input type="radio" value="2" name="stationmaster">屏蔽以下站长</label>
                  </div>
                </div>

                <div class="form-group">
                  <label  class="col-sm-2 control-label"></label>
                  <div class="col-sm-4">
                    <textarea class="form-control" id="stationmaster" rows="3" disabled></textarea>
                    <span style="color: #666;">多个站站长用英文,隔开</span>
                  </div>

                </div>


                <div class="form-group">
                  <label  class="col-sm-2 control-label">网站限制</label>
                  <div class="col-sm-4">
                    <label class="radio-inline">
                      <input type="radio" value="0" name="website" checked>不限</label>
                    <label class="radio-inline">
                      <input type="radio" value="1" name="website">允许以下网站</label>
                    <label class="radio-inline">
                      <input type="radio" value="2" name="website">屏蔽以下网站</label>
                  </div>
                </div>

                <div class="form-group">
                  <label  class="col-sm-2 control-label"></label>
                  <div class="col-sm-4">
                    <textarea class="form-control" id="website" rows="3" disabled></textarea>
                    <span style="color: #666;">多个站点用英文,隔开</span>
                  </div>
                </div>


                <div class="form-group">
                  <label  class="col-sm-2 control-label">周期日程</label>
                  <div class="col-sm-4">
                    <label class="radio-inline">
                      <input type="radio" value="0" name="cycle"  checked>不限</label>
                    <label class="radio-inline">
                      <input type="radio" value="1"  name="cycle">设定周期日程</label>
                  </div>
                </div>
                <div class="form-group" id="cycle" hidden>
                  <label  class="col-sm-2 control-label"></label>
                  <div class="col-sm-10">
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="1" name="z1" >周一</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="0" name="w1" >0</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="1" name="w1" >1</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="2" name="w1" >2</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="3" name="w1" >3</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="4" name="w1" >4</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="5" name="w1" >5</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="6" name="w1" >6</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="7" name="w1" >7</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="8" name="w1" >8</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="9" name="w1" >9</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="10" name="w1" >10</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="11" name="w1" >11</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="12" name="w1" >12</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="13" name="w1" >13</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="14" name="w1" >14</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="15" name="w1" >15</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="16" name="w1" >16</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="17" name="w1" >17</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="18" name="w1" >18</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="19" name="w1" >19</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="20" name="w1" >20</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="21" name="w1" >21</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="22" name="w1" >22</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="23" name="w1" >23</label>
                  </div>
                  <label  class="col-sm-2 control-label"></label>
                  <div class="col-sm-10">
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="2" name="z2" >周二</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="0" name="w2" >0</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="1" name="w2" >1</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="2" name="w2" >2</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="3" name="w2" >3</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="4" name="w2" >4</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="5" name="w2" >5</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="6" name="w2" >6</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="7" name="w2" >7</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" value="8" name="w2" >8</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="9" name="w2" >9</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="10" name="w2" >10</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="11" name="w2" >11</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="12" name="w2" >12</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="13" name="w2" >13</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="14" name="w2" >14</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="15" name="w2" >15</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="16" name="w2" >16</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="17" name="w2" >17</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="18" name="w2" >18</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="19" name="w2" >19</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="20" name="w2" >20</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="21" name="w2" >21</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="22" name="w2" >22</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="23" name="w2" >23</label>
                  </div>
                  <label  class="col-sm-2 control-label"></label>
                  <div class="col-sm-10">
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="3" name="z3" >周三</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="0" name="w3" >0</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="1" name="w3" >1</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="2" name="w3" >2</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="3" name="w3" >3</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="4" name="w3" >4</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="5" name="w3" >5</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="6" name="w3" >6</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="7" name="w3" >7</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="8" name="w3" >8</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="9" name="w3" >9</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="10" name="w3" >10</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="11" name="w3" >11</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="12" name="w3" >12</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="13" name="w3" >13</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="14" name="w3" >14</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="15" name="w3" >15</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="16" name="w3" >16</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="17" name="w3" >17</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="18" name="w3" >18</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="19" name="w3" >19</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="20" name="w3" >20</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="21" name="w3" >21</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="22" name="w3" >22</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="23" name="w3" >23</label>
                  </div>
                  <label  class="col-sm-2 control-label"></label>
                  <div class="col-sm-10">
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="4" name="z4" >周四</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="0" name="w4" >0</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="1" name="w4" >1</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="2" name="w4" >2</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="3" name="w4" >3</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="4" name="w4" >4</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="5" name="w4" >5</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="6" name="w4" >6</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="7" name="w4" >7</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="8" name="w4" >8</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="9" name="w4" >9</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="10" name="w4" >10</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="11" name="w4" >11</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="12" name="w4" >12</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="13" name="w4" >13</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" value="14" name="w4" >14</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="15" name="w4" >15</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="16" name="w4" >16</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="17" name="w4" >17</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="18" name="w4" >18</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" value="19" name="w4" >19</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="20" name="w4" >20</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="21" name="w4" >21</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="22" name="w4" >22</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="23" name="w4" >23</label>
                  </div>
                  <label  class="col-sm-2 control-label"></label>
                  <div class="col-sm-10">
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="5" name="z5" >周五</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="0" name="w5" >0</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="1" name="w5" >1</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="2" name="w5" >2</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="3" name="w5" >3</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="4" name="w5" >4</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="5" name="w5" >5</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="6" name="w5" >6</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="7" name="w5" >7</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="8" name="w5" >8</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="9" name="w5" >9</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="10" name="w5" >10</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled  value="11" name="w5" >11</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="12" name="w5" >12</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="13" name="w5" >13</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="14" name="w5" >14</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="15" name="w5" >15</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="16" name="w5" >16</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="17" name="w5" >17</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="18" name="w5" >18</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="19" name="w5" >19</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="20" name="w5" >20</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="21" name="w5" >21</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="22" name="w5" >22</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="23" name="w5" >23</label>
                  </div>
                  <label  class="col-sm-2 control-label"></label>
                  <div class="col-sm-10">
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="6" name="z6" >周六</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="0" name="w6" >0</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="1" name="w6" >1</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="2" name="w6" >2</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="3" name="w6" >3</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="4" name="w6" >4</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="5" name="w6" >5</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="6" name="w6" >6</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="7" name="w6" >7</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="8" name="w6" >8</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="9" name="w6" >9</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="10" name="w6" >10</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="11" name="w6" >11</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="12" name="w6" >12</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="13" name="w6" >13</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="14" name="w6" >14</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="15" name="w6" >15</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="16" name="w6" >16</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="17" name="w6" >17</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="18" name="w6" >18</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="19" name="w6" >19</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="20" name="w6" >20</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="21" name="w6" >21</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="22" name="w6" >22</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="23" name="w6" >23</label>
                  </div>
                  <label  class="col-sm-2 control-label"></label>
                  <div class="col-sm-10">
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="7" name="z7" >周日</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="0" name="w7" >0</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="1" name="w7" >1</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="2" name="w7" >2</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="3" name="w7" >3</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="4" name="w7" >4</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="5" name="w7" >5</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="6" name="w7" >6</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="7" name="w7" >7</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="8" name="w7" >8</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="9" name="w7" >9</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="10" name="w7" >10</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" value="11" name="w7" >11</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="12" name="w7" >12</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="13" name="w7" >13</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="14" name="w7" >14</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="15" name="w7" >15</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="16" name="w7" >16</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="17" name="w7" >17</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="18" name="w7" >18</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="19" name="w7" >19</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="20" name="w7" >20</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="21" name="w7" >21</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="22" name="w7" >22</label>
                    <label class="checkbox-inline">
                      <input type="checkbox" disabled value="23" name="w7" >23</label>
                  </div>
                </div>

                <div class="form-group">
                  <label id="motext" for="unit_price" class="col-sm-2 control-label">渠道单价</label>
                  <div class="col-sm-2">
                    <input type="number" name="unit_price" maxlength="10" class="form-control" id="unit_price">
                  </div>
                </div>
                <div class="form-group">
                  <label for="quota" class="col-sm-2 control-label">每日限额</label>
                  <div class="col-sm-2">
                    <input type="number" name="quota" maxlength="20" class="form-control" id="quota">
                  </div>
                </div>
                <div class="form-group">
                  <label for="quota" class="col-sm-2 control-label">扣量(%)</label>
                  <div class="col-sm-2">
                    <input type="number" name="kou" maxlength="20" class="form-control" id="kou">
                  </div>
                </div>
              </div>

              <!-- /.box-body -->
              <div class="box-footer">
                <button type="button" onclick="goBack();" class="btn btn-default">取消</button>
                <button type="button" onclick="submitForm()" class="btn btn-primary">提交</button>
              </div>
              <!-- /.box-footer -->
            </form>
          </div>
        </div>
      </div>
    </section>
  </div>
  <!--底部-->
  <footer id="footerDiv" class="main-footer">
    <!--#include  file="/pages/admin/footer.html"-->
  </footer>

  <!-- Control Sidebar -->
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/bower_components/morris.js/morris.min.js"></script>
<script src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<script src="/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<script src="/bower_components/fastclick/lib/fastclick.js"></script>
<script src="/dist/js/adminlte.min.js"></script>

<script src="/dist/js/layer/layer.js"></script>
<script src="/dist/js/laydate/laydate.js"></script>
<script src="/dist/js/bootstrapValidator.min.js"></script>

<script src="/dist/js/uploadPreview.min.js"></script>
<script src="/dist/js/ajaxfileupload.js"></script>

<script>
    var flag=true;
    var sizeMap={};
    var typeMap={};
    var mainImageStatus = 1;

    $("#mainImage").uploadPreview({
        Img : "mainPicture",
        Width : 200,
        Height : 100
    });
    $('#mainPicture').attr('src','/dist/img/addimg.jpg');

    $("#gifImage").uploadPreview({
        Img : "gifPicture",
        Width : 200,
        Height : 100
    });
    $('#gifPicture').attr('src','/dist/img/addimg.jpg');

    function AddImg() {
        // a标签绑定onclick事件
        $('#mainImage').click();
    }

    function AddGif() {
        // a标签绑定onclick事件
        $('#gifImage').click();
    }

    function AddVideo() {
        // a标签绑定onclick事件
        $('#mainVideo').click();
    }

    function getFileUrl(sourceId) {
        var url;
        if (navigator.userAgent.indexOf("MSIE") >= 1||(!!window.ActiveXObject || "ActiveXObject" in window)) { // IE
            url = document.getElementById(sourceId).value;
        } else if (navigator.userAgent.indexOf("Firefox") > 0) { // Firefox
            url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
        } else if (navigator.userAgent.indexOf("Chrome") > 0) { // Chrome
            url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
        }
        return url;
    }

    $(function () {
        laydate.render({
            elem: '#end_date' //指定元素
        });
        let url = "/lmgame/adsplan/get";
        $.ajax({
            type: 'POST',
            url: url,
            data: {
                "id": store.get("adsid")
            },
            dataType: "json",
            success: function (data) {
                // store.remove("adsid")
                if (data.code != 0) {
                    layer(data.msg);
                    return;
                } else {
                    let bhtml = "";
                    let budgets = data.data.budgets;
                    $.each(budgets, function (i, v) {
                        let value = v.id;
                        bhtml += '<option value="'+value+'">'+v.budgetname+'</option>';
                    });
                    $("#budgetid").html(bhtml);

                    let ghtml = "";
                    let games = data.data.games;
                    $.each(games, function (i, v) {
                        let value = v.id;
                        ghtml += '<option value="'+value+'">'+v.name+'</option>';
                    });
                    $("#gameid").html(ghtml);

                    let shtml = "<option>请选择</option>";
                    let styles = data.data.styles;
                    $.each(styles, function (i, v) {
                        let value = v.id;
                        shtml += '<option value="'+value+'">'+v.name+'</option>';
                        sizeMap[value] = v.sizes;
                        typeMap[value] = v.type_range;
                    });
                    $("#styleid").html(shtml);

                    if (data.data.adsplan != null){
                        let adsplan = data.data.adsplan;
                        $("#id").val(adsplan.ads.id);
                        $("#budgetid").val(adsplan.plan.budgetid);
                        $("#gameid").val(adsplan.ads.gameid);
                        $("#styleid").val(adsplan.ads.styleid);
                        $("#adsname").val(adsplan.ads.adsname);
                        $("#url").val(adsplan.ads.url);
                        $("#priority").val(adsplan.ads.priority);

                        $("#unit_price").val(adsplan.plan.unit_price);
                        $("#quota").val(adsplan.plan.quota);
                        $("#kou").val(adsplan.plan.kou);
                        $("#network").val(adsplan.plan.network);
                        $("input:radio[value='"+adsplan.plan.flow+"']").attr('checked','true');

                        let sizes = sizeMap[adsplan.ads.styleid].split(",");
                        let shtml = "<option>请选择</option>";
                        $.each(sizes, function (i, v) {
                            shtml += '<option value="'+v+'">'+v+'</option>';
                        });
                        $("#size").html(shtml);
                        $("#size").val(adsplan.ads.width+"*"+adsplan.ads.height);

                        let type_range = typeMap[adsplan.ads.styleid].split(",");
                        let thtml = "";
                        $.each(type_range, function (i, v) {
                            thtml += '<option value="'+v+'">'+v+'</option>';
                        });
                        $("#type").html(thtml);
                        $("#type").val(adsplan.plan.type);
                        if(adsplan.plan.type == 'cps'){
                            $("#motext").html("分成比例");
                        }

                        $("#width").val(adsplan.ads.width);
                        $("#height").val(adsplan.ads.height);
                        $("#mainPicture").css("width", adsplan.ads.width);
                        $("#mainPicture").css("height", adsplan.ads.height);
                        $("#mainPicture").attr("src", adsplan.ads.imgurl);
                        $("#gifPicture").css("width", adsplan.ads.width);
                        $("#gifPicture").css("height", adsplan.ads.height);
                        if(adsplan.ads.gifurl === ''){
                            $("#gifPicture").attr("src", "/dist/img/addimg.jpg");
                        }else{
                            $("#gifPicture").attr("src", adsplan.ads.gifurl);
                        }
                        $("#videUrl").val(adsplan.ads.videourl);
                        mainImageStatus = 0;
                        if(adsplan.plan.browser !== ''){
                            $("input:checkbox[name='browser']").removeAttr("disabled");
                            let param = adsplan.plan.browser .split(":");
                            $("input[name='isbrowser'][value='"+param[0]+"']").prop({checked:true});
                            let bs = param[1].split(",");
                            $.each(bs, function (i, v) {
                                $("input:checkbox[name='browser'][value='"+v+"']").prop({checked:true});
                            })
                        }

                        if(adsplan.plan.end_date !== null){
                            $("#end_date").removeAttr("disabled");
                            $("input[name='end_date'][value='1']").prop({checked:true});
                            $("#end_date").val(adsplan.plan.end_date);
                        }

                        if(adsplan.plan.stationmaster !== ''){
                            $("#stationmaster").removeAttr("disabled");
                            let param = adsplan.plan.stationmaster.split(":");
                            $("input[name='stationmaster'][value='"+param[0]+"']").prop({checked:true});
                            $("#stationmaster").val(param[1]);
                        }

                        if(adsplan.plan.website !== ''){
                            $("#website").removeAttr("disabled");
                            let param = adsplan.plan.website.split(":");
                            $("input[name='website'][value='"+param[0]+"']").prop({checked:true});
                            $("#website").val(param[1]);
                        }

                        if(adsplan.plan.cycle !== ''){
                            $("#cycle").show();
                            $("#cycle input").removeAttr("disabled");
                            $("input[name='cycle'][value='1']").prop({checked:true});
                            let dataMap = JSON.parse(adsplan.plan.cycle);
                            $.each(dataMap,function(key,values){
                                $("input[name='z"+key+"']").prop({checked:true});
                                let ws = values.split(",");
                                $.each(ws,function(i,v){
                                    $("input[name='w"+key+"'][value='"+v+"']").prop({checked:true});
                                });
                            });
                        }
                    }else {
                        // let sizes = styles[0].sizes.split(",");
                        // let shtml = "<option>请选择</option>";
                        // $.each(sizes, function (i, v) {
                        //     shtml += '<option value="'+v+'">'+v+'</option>';
                        // });
                        // $("#size").html(shtml);

                        // let type_range = styles[0].type_range.split(",");
                        // let thtml = "";
                        // $.each(type_range, function (i, v) {
                        //     thtml += '<option value="'+v+'">'+v+'</option>';
                        // });
                        // $("#type").html(thtml);
                    }
                }
            },
            error: function (xhr, ts, et) { //XMLHttpRequest, textStatus, errorThrown
                if (xhr.status === 400) {
                    window.location.href = "/pages/admin/login.html";
                }
                if (xhr.status === 403) {
                    window.location.href = "/403.html";
                }
            }
        });

        $("#type").change(function () {
            if($(this).val() == 'cps'){
                $("#motext").html("分成比例");
            }else{
                $("#motext").html("渠道单价");
            }
        });

        $("#styleid").change(function () {
            let id = $(this).val();
            let sizes = sizeMap[id].split(",");
            let shtml = "<option>请选择</option>";
            $.each(sizes, function (i, v) {
                shtml += '<option value="'+v+'">'+v+'</option>';
            });
            $("#size").html(shtml);

            let type_range = typeMap[id].split(",");
            let thtml = "";
            $.each(type_range, function (i, v) {
                thtml += '<option value="'+v+'">'+v+'</option>';
            });
            $("#type").html(thtml);
            if($("#type").val() == 'cps'){
                $("#motext").html("分成比例");
            }else{
                $("#motext").html("渠道单价");
            }
        });

        $("#size").change(function () {
            let size = $(this).val().split("*");
            $("#width").val(size[0]);
            $("#height").val(size[1]);
            $("#mainPicture").css("width", size[0]);
            $("#mainPicture").css("height", size[1]);
            $("#gifPicture").css("width", size[0]);
            $("#gifPicture").css("height", size[1]);
        });

        $("input[name='isbrowser']").change(function () {
            if($(this).val() === '0'){
                $("input:checkbox[name='browser']").attr("disabled",true);
                $("input:checkbox[name='browser']").prop({checked:false});
            }else{
                $("input:checkbox[name='browser']").removeAttr("disabled");
            }
        });

        $("input[name='end_date']").change(function () {
            if($(this).val() === '0'){
                $("#end_date").attr("disabled",true);
                $("#end_date").val("");
            }else{
                $("#end_date").removeAttr("disabled");
            }
        });

        $("input[name='stationmaster']").change(function () {
            if($(this).val() === '0'){
                $("#stationmaster").attr("disabled",true);
                $("#stationmaster").val("");
            }else{
                $("#stationmaster").removeAttr("disabled");
            }
        });

        $("input[name='website']").change(function () {
            if($(this).val() === '0'){
                $("#website").attr("disabled",true);
                $("#website").val("");
            }else{
                $("#website").removeAttr("disabled");
            }
        });

        $("input[name='cycle']").change(function () {
            if($(this).val() === '1'){
                $("#cycle").show();
                $("#cycle input").removeAttr("disabled");
            }else{
                $("#cycle").hide();
                $("#cycle input").attr("disabled",true);
            }
        });

        $("input[name^='z']").change(function () {
            if($(this).is(":checked")){
                $("input[name='w"+$(this).val()+"']").prop({checked:true});
            }else{
                $("input[name='w"+$(this).val()+"']").prop({checked:false});
            }
        });

        $("input[name^='w']").change(function () {
            if($(this).is(":checked")){
                let name = $(this).attr("name");
                name = name.substring(1);
                $("input[name='z"+name+"']").prop({checked:true});
            }else{
                let name = $(this).attr("name");
                let all = $("input:checkbox[name='"+name+"']:checked").map(function(index,elem) {
                    return $(elem).val();
                }).get().join(',');
                if(all === ''){
                    name = name.substring(1);
                    $("input[name='z"+name+"']").prop({checked:false});
                }
            }
        });

        $("#mainVideo").bind('change', function () {
            $("#videUrl").val(getFileUrl(this.id));
        });
    });

    function submitForm() {
        let style=$("#styleid").val();
        if(style =="请选择"){
            layer.msg("请选择广告样式");
            return
        }
        let width=$("#width").val();
        if(width ==""){
            layer.msg("请选择广告尺寸");
            return
        }
        if (mainImageStatus === 1) {
            layer.msg('请上传图片');
            return;
        }

        if($("#adsname").val()==''){
            let adsname='创建于'+new Date().Format("yyyy-MM-dd HH:mm:ss");
            $("#adsname").val(adsname);
        }

        if($("#url").val() == ''){
            layer.msg('请输入广告地址');
            return;
        }

        let formMap={};
        formMap["ads.gameid"] = $("#gameid").val();
        formMap["ads.adsname"] = $("#adsname").val();
        formMap["ads.styleid"] = $("#styleid").val();
        formMap["ads.width"] = $("#width").val();
        formMap["ads.height"] = $("#height").val();
        formMap["ads.url"] = $("#url").val();
        let priority = $("#priority").val();
        if(priority === '' || priority == null){
            priority = 0;
        }
        formMap["ads.priority"] = priority;

        formMap["plan.plan_name"] = $("#adsname").val()+"--计划";
        formMap["plan.budgetid"] = $("#budgetid").val();
        formMap["plan.type"] = $("#type").val();
        formMap["plan.flow"] = $("input[name='flow']:checked").val();
        let network = $("#network").val();
        if(network !== ''){
            formMap["plan.network"] = network;
        }
        formMap["plan.network"] = $("#network").val();
        if($('input[name="isbrowser"]:checked ').val() !== '0') {
            let browser = $("input:checkbox[name='browser']:checked").map(function(index,elem) {
                return $(elem).val();
            }).get().join(',');
            formMap["plan.browser"] = $('input[name="isbrowser"]:checked ').val() + ":" + browser;
        }

        if($('input[name="end_date"]:checked ').val() !== '0') {
            formMap["plan.end_date"] = $("#end_date").val();
        }
        if($('input[name="stationmaster"]:checked ').val() !== '0') {
            formMap["plan.stationmaster"] = $('input[name="stationmaster"]:checked ').val()+":"+$("#stationmaster").val();
        }
        if($('input[name="website"]:checked ').val() !== '0') {
            formMap["plan.website"] = $('input[name="website"]:checked ').val()+":"+$("#website").val();
        }
        if($('input[name="cycle"]:checked ').val() !== '0') {
            let dayMap = {};
            let z = $("input:checkbox[name^='z']:checked").map(function(index,elem) {
                return $(elem).val();
            }).get();
            $.each(z, function (i, v) {
                dayMap[v] = $("input:checkbox[name='w"+v+"']:checked").map(function(index,elem) {
                    return $(elem).val();
                }).get().join(',');
            });
            let cycle = JSON.stringify(dayMap);
            formMap["plan.cycle"] = cycle;
        }

        let unit_price = $("input[name='unit_price']").val();
        if(unit_price <= 0 || unit_price === ''){
            layer.msg("渠道单价必须填写");
            return;
        }

        formMap["plan.unit_price"] = unit_price;
        formMap["plan.quota"] = $("input[name='quota']").val();
        formMap["plan.kou"] = $("input[name='kou']").val();

        let url="/lmgame/adsplan/add";

        let id =$("#id").val();
        if(id !== ''){
            formMap["ads.id"] = id;
            formMap["plan.id"] = id;
            url = "/lmgame/adsplan/update";
        }

        $.ajaxFileUpload({
            url: url, //用于文件上传的服务器端请求地址
            type: 'POST',
            fileElementId: ['mainImage','gifImage','mainVideo'], //文件上传域的ID
            dataType: 'json', //返回值类型 一般设置为json
            data: formMap,
            success: function(data) {
                // $("#infoConfirm").modal("hide");
                if(data.code === 0) {
                    layer.msg('保存成功', {
                        icon: 1,
                        time: 1000 //3秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        flag=true;
                        window.location.href = "adsList.html";
                    });
                } else {
                    layer.msg(data.msg);
                }
            },
            error: function (xhr, ts, et) { //XMLHttpRequest, textStatus, errorThrown
                if (xhr.status === 400) {
                    window.location.href = "/pages/admin/login.html";
                }
                if (xhr.status === 403) {
                    window.location.href = "/403.html";
                }
            }
        });
    }

    function  goBack() {
        window.history.back(-1);
    }

    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }

    Date.prototype.Format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "H+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    };

    function checkMainImage() {
        mainImageStatus = 0;
    }

</script>
</body>
</html>
